package com.lau.listener;

import com.lau.utils.DateUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author:Lau
 * @create: 2023-10-13 13:30
 * @Description: 订单超期监听
 */
@Component
public class OrderExpirationListener extends KeyExpirationEventMessageListener {


    public OrderExpirationListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {
        final String expiredKey = message.toString();
        System.out.println("我过期了" + expiredKey+"当前时间:"+ DateUtils.getTime());
    }

}
